#ifndef QMCPLUSPLUS_PROFILER_H
#define QMCPLUSPLUS_PROFILER_H
#if defined(USE_LIBHPM)
#include <libhpm.h>
#endif
  namespace mpi {
#if defined(USE_LIBHPM)
  struct profiler
  {
    int task_id;
    int current_event;

    profiler(int pid, const string& aname="kicker")
      : task_id(pid), current_event(0)
    {
      hpmInit(pid,const_cast<char*>(aname.c_str()));
    }

    ~profiler() { hpmTerminate(task_id); }

    inline int start_event(const string& aname)
    {
      hpmStart(++current_event,const_cast<char*>(aname.c_str()));
      return current_event;
    }

    inline void stop(int i)
    {
      hpmStop(i);
    }
  };
#else
  /** default empty profiler */
  struct profiler
  {
    inline profiler(int pid, const string& aname="kicker"){ }
    inline ~profiler() { }
    inline int start_event(const string& aname) { return 0; }
    inline void stop(int i) { }
  };
#endif
}
#endif
